<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>系统设置</title>
    <script src="/static/statics/libs/jquery-1.7.2.js"></script>
    <link rel="stylesheet" href="/static/statics/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/statics/plugins/layui/css/layui.css" media="all">
    <script src="/static/statics/plugins/layer/layer.js"></script>
    <script src="/static/statics/plugins/layui/layui.js"></script>
    <link rel="stylesheet" href="/static/common/css/cyStyle.css">
    <link rel="stylesheet" href="/static/common/css/cyType.css">
    <script src="/static/common/js/whole/cyLayer.js"></script>
    <script src="/static/common/js/whole/common.js"></script>
    <script src="/static/common/js/selectTool.js"></script>
</head>
<body>

<div class="menus" style="margin:5px;">
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <label class="layui-form-label" pane>数据源设置</label>
            <div class="layui-input-inline"><select name="initDbsource" id="initDbsource">
                <option value="1" selected>项目启动时主动初始化数据源</option>
                <option value="2">手动初始化数据源</option>
            </select>
                <input type="hidden" name="ids" th:value="${obj.id}">
                <input type="hidden" id="initDbsourceVal" th:value="${obj.initDbsource}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" pane>日志设置</label>
            <div class="layui-input-inline">
                <select name="col3" id="col3">
                    <option value="1" selected>记录SQL执行日志</option>
                    <option value="2">不记录SQL执行日志</option>
                </select>
                <input type="hidden" id="col3Val" th:value="${obj.col3}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" pane>锁屏设置</label>
            <div class="layui-input-inline">
                <select name="enabledLockView" id="enabledLockView">
                    <option value="0" selected>开启锁屏功能</option>
                    <option value="1">关闭锁屏功能</option>
                </select>
                <input type="hidden" id="enabledLockViewVal" th:value="${obj.enabledLockView}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" pane>文档设置</label>
            <div class="layui-input-inline">
                <select name="enabledHelp" id="enabledHelp">
                    <option value="0" selected>开启帮助文档展示</option>
                    <option value="1">关闭帮助文档展示</option>
                </select>
                <input type="hidden" id="enabledHelpVal" th:value="${obj.enabledHelp}">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" pane>分页条数</label>
            <div class="layui-input-inline">
                <input type="text" id="pageLimitMax" th:value="${obj.pageLimitMax}" class="layui-input">
            </div>
            <div class="layui-form-mid layui-word-aux">默认查询时分页最大查询条数,目前支持mysql、oracle<br>SQL执行时没有分页条件会走此限制,sql中有分页条件不会走此限制</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" pane>语句限制</label>
            <div class="layui-input-inline">
                <input type="text" id="riskText" th:value="${obj.riskText}" class="layui-input">
            </div>
                <div class="layui-form-mid layui-word-aux">执行SQL时检查语句包含危险关键词不允许执行;<br>小写输入关键词支持多个用,分割</div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label" pane>清空操作</label>
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-danger"
                        onclick="deleteOne('清除SQL执行日志','/logManager/deleteLog/1');return false;">清空SQL执行记录
                </button>
                <button class="layui-btn layui-btn-danger"
                        onclick="deleteOne('清除用户登陆日志','/logManager/deleteLog/2','1');return false;">清空登陆系统记录
                </button>
                <button class="layui-btn layui-btn-danger"
                        onclick="deleteOne('清除作业日志','/timingManager/jobLogDelete','1');return false;">清空作业执行记录
                </button>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="saveBtn">保存设置</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form', 'table', 'element'], function () {
        var form = layui.form;
        table = layui.table;
        element = layui.element;

        $("#initDbsource").each(function () {
            $(this).children("option").each(function () {
                if (this.value == $("#initDbsourceVal").val()) {
                    $(this).attr("selected", "selected");
                }
            });
        });
        $("#col3").each(function () {
            $(this).children("option").each(function () {
                if (this.value == $("#col3Val").val()) {
                    $(this).attr("selected", "selected");
                }
            });
        });

        $("#enabledLockView").each(function () {
            $(this).children("option").each(function () {
                if (this.value == $("#enabledLockViewVal").val()) {
                    $(this).attr("selected", "selected");
                }
            });
        });

        $("#enabledHelp").each(function () {
            $(this).children("option").each(function () {
                if (this.value == $("#enabledHelpVal").val()) {
                    $(this).attr("selected", "selected");
                }
            });
        });

        form.render();

        $("#saveBtn").click(function () {
            var url = "/settingManager/updateSysSetUp";
            var params = {
                'initDbsource': $("#initDbsource").val(),
                'col3': $("#col3").val(),
                'id': 1,
                'enabledHelp': $("#enabledHelp").val(),
                'enabledLockView': $("#enabledLockView").val(),
                'pageLimitMax':$("#pageLimitMax").val(),
                'riskText':$("#riskText").val()
            };
            var indexOpen = Loading.open(2, true);
            $.ajax({
                type: 'POST',
                url: url,
                data: params,
                dataType: "json",
                success: function (data) {
                    Loading.close(indexOpen);
                    if (data.code == 200) {
                        layer.msg("修改成功！", {icon: 1});
                    } else {
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                error: function (data) {
                    Loading.close(indexOpen);
                    Msg.error("执行异常!");
                }
            });
            return false;
        });
    });
</script>
</body>
</html>